#!/usr/bin/python3
# coding: utf-8
# authon: ren
from . import rd
def save_code(phone, code):
    rd.set(phone, code, 120)  # k, v, expires

def valid_code(phone, code):
    if rd.exists(phone):
        return rd.get(phone) == code
    return False

def has(phone):
    return rd.exists(phone)